<?php include $this->getViewFile('/common/Head') ?>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
  <?php include $this->getViewFile('/common/Nav') ?>
  <div class="h_a">查找</div>
  <form method="post" action="" id="searchForm">
    <div class="search_type cc mb10">
      <div class="mb10"> 
        会员类型：<?php echo Form::select(array(0=>'商家会员',1=>'买家会员',),$kind,'name="kind"','全部') ?>
        积分：
        <input type="text" name="score_floor" class="input length_1" value="<?php echo $score_floor?>" placeholder="选择起始时间">
        -
        <input type="text" name="score_upper" class="input length_1" value="<?php echo $score_upper?>" placeholder="选择结束时间">
       </div>
       <div class="mb10">
       注册时间：
        <input type="text" name="reg_floor" class="input length_2 J_date" value="<?php echo $reg_floor?>" placeholder="选择起始时间">
        -
        <input type="text" name="reg_upper" class="input length_2 J_date" value="<?php echo $reg_upper?>" placeholder="选择结束时间">
        登录时间：
        <input type="text" name="login_floor" class="input length_2 J_date" value="<?php echo $login_floor?>" placeholder="选择起始时间">
        -
        <input type="text" name="login_upper" class="input length_2 J_date" value="<?php echo $login_upper?>" placeholder="选择结束时间">
       </div>
       <div class="mb10">
        关键字：<?php echo Form::select(array('email'=>'会员邮箱','uid'=>'会员id','username'=>'会员名称','phone'=>'手机号','taobao_user_nick'=>'旺旺号'),$sType,'name="sType"') ?>
        <input type="text" class="input length_2" name="keyword" style="width:200px;" value="<?php echo $keyword?>" placeholder="请输入搜索内容...">
        <button class="btn">搜索</button>
      </div>
    </div>
  </form>
  <div class="mb10"> 共有 ( <b><?php echo $count; ?></b> ) 个会员</div>
  <form name="myform" action="<?php echo AdminBase::U("delete") ?>" method="post" class="J_ajaxForm">
    <div class="table_list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <td width="100" align="center"><input type="checkbox" class="J_check_all" data-direction="x" data-checklist="J_check_x">
              全选</td>
            <td align="center">会员名称</td>
            <td align="center">邮箱</td>
            <td align="center">会员类型</td>
            <td align="center">积分</td>
            <td align="center">手机号</td>
            <td align="center">生日</td>
            <td align="center">性别</td>
            <td align="center">注册时间</td>
            <td align="center">最后登录</td>
            <td align="center">操作</td>
          </tr>
        </thead>
        <tbody>
          <?php
		  foreach($data as $rs){
		  ?>
          <tr>
            <td align="center"><input type="checkbox" class="J_check" data-yid="J_check_y" data-xid="J_check_x" name="ids[]" value="<?php echo $rs->uid; ?>" id="att_<?php echo $rs->uid; ?>"><?php echo $rs->uid; ?></td>
            <td><?php echo $rs->username; ?>&nbsp;<a href="<?php echo AdminBase::U("userlogin",array('uid'=>$rs->uid)) ?>" target="_blank">登录</a></td>
            <td><?php echo $rs->email; ?></td>
            <td align="center"><?php echo $rs->kind == 0 ? '<font color="#0000FF">商家会员</font>' : '买家会员'; ?></td>
            <td align="center"><?php echo $rs->score;?></td>
            <td align="center"><?php echo $rs->phone;//RegionModel::model()->convertRid($rs->province);?> <?php //echo RegionModel::model()->convertRid($rs->city);?></td>
            <td align="center"><?php echo $rs->year;?>-<?php echo $rs->month;?>-<?php echo $rs-->day;?></td>
            <td align="center"><?php echo $rs->sex?($rs->sex == 1?'男':'女'):'未知';?></td>
            <td align="center"><?php echo date('Y-m-d H:i:s',$rs->regdate); ?></td>
            <td align="center"><?php echo date('Y-m-d H:i:s',$rs->lastlogintime); ?></td>
            <td align="center">
            <?php
			$op = array();
			if(RBAC::authenticate('edit')){
				$op[] = '<a class="J_ajax_edit" href="'.AdminBase::U("edit",array('uid'=>$rs->uid)).'">编辑</a>';
			}
			if(RBAC::authenticate('delete')){
				$op[] = '<a class="J_ajax_del" href="'.AdminBase::U("delete",array('uid'=>$rs->uid)).'">删除</a>';
			}
			if(RBAC::authenticate('relieve_wanwan')){
				$op[] = '<a class="J_ajax_relieve_wanwan" href="'.AdminBase::U("relieve_wanwan",array('uid'=>$rs->uid)).'">旺旺解除</a>';
			}
			echo implode(' | ',$op);
			?>
            </td>
          </tr>
          <?php
		  }
		  ?>
        </tbody>
      </table>
      <div class="p10">
        <div class="pages"><?php echo $Page;?></div>
      </div>
    </div>
  </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>
<script>
$(function(){
	//所有的删除操作，删除数据后刷新页面
    if ($('a.J_ajax_relieve_wanwan').length) {
        Wind.use('artDialog', 'iframeTools', function() {
            $('.J_ajax_relieve_wanwan').on('click', function(e) {
                e.preventDefault();
                var $_this = this,
                    $this = $($_this),
                    href = $this.prop('href'),
                    msg = $this.data('msg');
                art.dialog({
                    title: false,
                    icon: 'question',
                    content: '确定要解除用户旺旺绑定吗？',
                    follow: $_this,
                    close: function() {
                        $_this.focus();; //关闭时让触发弹窗的元素获取焦点
                        return true;
                    },
                    ok: function() {
                        $.getJSON(href).done(function(data) {
                            if (data.state === 'success') {
                                if (data.referer) {
                                    location.href = data.referer;
                                } else {
                                    reloadPage(window);
                                }
                            } else if (data.state === 'fail') {
                                art.dialog.alert(data.info);
                            }
                        });
                    },
                    cancelVal: '关闭',
                    cancel: true
                });
            });

        });
    }
});
</script>
</body>
</html>